package org.yray.sip.factory.inet;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.yray.sip.base.MsgType;
import org.yray.sip.creator.MessageCreator;
import org.yray.sip.factory.IdRuleComponent;
import org.yray.sip.factory.SipServerFactory;
import org.yray.sip.factory.StopWatchFactory;
import org.yray.sip.server.SipServerContext;
import org.yray.sip.server.SipServerHandler;
import org.yray.sip.server.SipSession;


@Service
public class SipComponent {


    @Autowired
    SipServerFactory sipServerFactory;

    @Autowired
    StopWatchFactory stopWatchFactory;

    @Autowired
    IdRuleComponent idRuleComponent;

    public void regExt(String ext, SipServerHandler sipServerHandler)
    {
        SipServerContext sipServerContext =sipServerHandler.getServerContext();
        SipSession sipSession=new SipSession(ext, sipServerContext.getSipIp(), sipServerContext.getSipPort(), sipServerContext.getRunIp(), sipServerContext.getRunPort());
        String msg= MessageCreator.getCreator(MsgType.REGISTER).createMsg(sipSession);
        sipServerHandler.sendToSipServer(sipSession,msg);
    }





}
